<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>component标签</title>
		<script src="js/vue.js" type="text/javascript" charset="utf-8"></script>
		<style>
			* {
				margin: 0;
				padding: 0;
			}

			body {
				width: 100%;
				height: 100%;
			}

			footer {
				height: 30px;
				width: 100%;
				background-color: #cccccc;
				position: fixed;
				left: 0;
				bottom: 0;
			}

			footer ul {
				list-style: none;
				height: 100%;
				display: flex;
				justify-content: space-between;
			}

			footer ul li {
				text-align: center;
				width: 33%;
				line-height: 30px;
			}
		</style>
	</head>
	<body>
		<div id="app">
			<keep-alive>
				<component :is="isWhitch"> </component>
			</keep-alive>
			<footer>
				<ul>
					<li @click=" isWhitch = 'home' ">首页</li>
					<li @click=" isWhitch = 'detail' ">详情</li>
					<li @click=" isWhitch = 'cart' ">购物车</li>
				</ul>
			</footer>
		</div>
		<script type="text/javascript">
			Vue.component("home", {
			template: `
			<div>
				<h1>首页</h1><input type="text"/>
			</div>
			`
			}),
			Vue.component("detail", {
				template: `
			<div>
				<h1>详情</h1>
			</div>
			`
			}),
			Vue.component("cart", {
				template: `
			<div>
				<h1>购物车</h1>
			</div>
			`
			}),
			new Vue({
				el: "#app",
				data: {
					isWhitch: 'home'
				}
			})
		</script>
	</body>
</html>
